/**   
* @Title: Test.java
* @Package com.an.springdatajpa
* @Description: TODO(用一句话描述该文件做什么)
* @author antch,861710865@qq.com   
* @date 2017年8月7日 上午11:58:24
* @version V1.0   
*/


package com.an.springdatajpa;

import static org.junit.Assert.assertNotNull;

import java.util.List;

import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
* @ClassName: Test
* @Description: TODO(测试Spring JPA)
* @author antch,861710865@qq.com
* @date 2017年8月7日 上午11:58:24
* 
*/

@SuppressWarnings("deprecation")
@RunWith(SpringJUnit4ClassRunner.class)
public class Test {

	@Autowired
	private UserDao userDao;
	
	@org.junit.Test
	public void testsave() {
		User user = new User("123", "123", "456", "654", "20170807");
		assertNotNull( userDao.save(user));
	}
	
	@org.junit.Test
	public void getUserByName() {
		List<User> users = userDao.getByUserNameOrEmail("123", "1");
		System.out.println(users);
		assertNotNull(users);
	}
	
	/**
	 * 测试分页查询
	 */
	@org.junit.Test
	public void testFY() {
		
		Sort sort = new Sort(Direction.DESC,"id");
		Pageable pageable = new PageRequest(1, 3, sort);
		System.out.println("************" + "分页查询" + "************");
		System.out.println(userDao.findAll(pageable).getSize());
		System.out.println("************" + "分页查询" + "************");

	}
	
	@org.junit.Test
	public void testModify() {
		System.out.println("************" + "修改" + "************");
		System.out.println(userDao.modifyByIdAndUserId("安天池，哈哈哈哈",Long.parseLong("5") ));
		System.out.println("************" + "修改" + "************");

	}
	
}
